<?	
    class App
    {
        private static $nss = array();
        private static $settings = array();

        static function namespace($name, $autoInit = true){
            $ns = str_replace('.', '/', $name) . '/';			
            $init = $ns . 'Init.php';
			
            self::$nss[] = $ns;

            if($autoInit && is_file($init))
            {
                include $init;
            }
        }

        static function getNS()
        {
            return self::$nss;
        }

        static function scanDirs($dir, &$items = array())
        {
            $ignore = array('.', '..');
            $items[] = $dir;

            foreach(scandir($dir) as $name)
            {
                if(in_array($name, $ignore ))
                    continue;

                $file = $dir . $name. "/";

                if(is_dir($file))
                {
                    self::scanDirs($file, $items);
                }
            }

            return $items;
        }

        static function scanFiles($dir, &$items = array())
        {
            $ignore = array('.', '..');

            foreach(scandir($dir) as $name)
            {
                if(in_array($name, $ignore ))
                    continue;

                $file = $dir . $name;

                if(is_dir($file))
                {
                    self::scanFiles($file . "/", $items);
                }
                else
                {
                    $items[] = array(
                        'name' => $name,
                        'path' => $file
                    );
                }
            }

            return $items;
        }

        static function set($key, $val)
        {
            self::$settings[$key] = $val;
        }

        static function get($key)
        {
            return self::$settings[$key];
        }
    }
?>